
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>PHP页面静态化 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="laiq">
        
        
    
    <link rel="stylesheet" href="../../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-alerts/style.css">
                
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-terminal/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-toggle-chapters/toggle.css">
                
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
        <link rel="stylesheet" href="../../../styles/website.css">
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="../../interview/" />
    
    
    <link rel="prev" href="./" />
    

    
        <link rel="shortcut icon" href='../../../assets/images/favicon.ico' type="image/x-icon">
    
    
        <link rel="bookmark" href='../../../assets/images/favicon.ico' type="image/x-icon">
    
    
        <link rel="apple-touch-icon" href='../../../assets/images/wukong.png'>
    
    
        
        <link rel="apple-touch-icon" sizes="120x120" href="../../../assets/images/wukong.png">
        
        <link rel="apple-touch-icon" sizes="180x180" href="../../../assets/images/wukong.png">
        
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../../">
            
                <a href="../../../">
            
                    
                    简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../../node/HTTP作用域、上下文.html">
            
                <a href="../../node/HTTP作用域、上下文.html">
            
                    
                    Node 学习
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../../node/HTTP作用域、上下文.html">
            
                <a href="../../node/HTTP作用域、上下文.html">
            
                    
                    HTTP 作用域、上下文
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../../node/Event事件.html">
            
                <a href="../../node/Event事件.html">
            
                    
                    Event 事件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../../node/Request.html">
            
                <a href="../../node/Request.html">
            
                    
                    Request
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="../../node/爬虫.html">
            
                <a href="../../node/爬虫.html">
            
                    
                    爬虫
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.5" data-path="../../node/HTTP跨域.html">
            
                <a href="../../node/HTTP跨域.html">
            
                    
                    HTTP 跨域
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.6" data-path="../../node/HTML5新特性.html">
            
                <a href="../../node/HTML5新特性.html">
            
                    
                    HTML5 新特性
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../设计模式/">
            
                <a href="../设计模式/">
            
                    
                    PHP 学习
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../设计模式/">
            
                <a href="../设计模式/">
            
                    
                    设计模式
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1.1" data-path="../设计模式/1.单例模式.html">
            
                <a href="../设计模式/1.单例模式.html">
            
                    
                    1.单例模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.1.2" data-path="../设计模式/2.抽象工厂模式.html">
            
                <a href="../设计模式/2.抽象工厂模式.html">
            
                    
                    2.抽象工厂模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.1.3" data-path="../设计模式/3.构造模式.html">
            
                <a href="../设计模式/3.构造模式.html">
            
                    
                    3.构造模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.1.4" data-path="../设计模式/4.原型模式.html">
            
                <a href="../设计模式/4.原型模式.html">
            
                    
                    4.原型模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.1.5" data-path="../设计模式/5.工厂方法模式.md">
            
                <span>
            
                    
                    5.工厂方法模式
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="./">
            
                <a href="./">
            
                    
                    随手笔记
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter active" data-level="1.3.2.1" data-path="PHP页面静态化.html">
            
                <a href="PHP页面静态化.html">
            
                    
                    PHP页面静态化
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../../interview/">
            
                <a href="../../interview/">
            
                    
                    面试相关
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../../.." >PHP页面静态化</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h2 id="&#x9759;&#x6001;&#x5316;&#x4ECB;&#x7ECD;">&#x9759;&#x6001;&#x5316;&#x4ECB;&#x7ECD;</h2>
<p>php&#x9759;&#x6001;&#x5316;</p>
<ul>
<li>&#x7EAF;&#x9759;&#x6001;<ul>
<li>&#x5C40;&#x90E8;&#x7EAF;&#x9759;&#x6001;</li>
<li>&#x5168;&#x90E8;&#x7EAF;&#x9759;&#x6001;</li>
</ul>
</li>
<li>&#x4F2A;&#x9759;&#x6001;<ul>
<li>&#x52A8;&#x6001;URL&#x5730;&#x5740;&#x8BBE;&#x7F6E;&#x6210;&#x9759;&#x6001;&#x5F62;&#x5F0F;(Apache,Nginx)</li>
</ul>
</li>
</ul>
<h2 id="buffer&#x8BA4;&#x77E5;">Buffer&#x8BA4;&#x77E5;</h2>
<p>&#x5185;&#x5BB9;-&gt;php buffer-&gt;tcp-&gt;&#x7EC8;&#x7AEF;</p>
<pre><code class="lang-php"><span class="hljs-comment">//php.ini</span>
output_buffering = on

<span class="hljs-comment">//&#x83B7;&#x53D6;php&#x7F13;&#x51B2;&#x533A;&#x7684;&#x5185;&#x5BB9;</span>
ob_get_contents();

<span class="hljs-comment">//&#x4EE3;&#x7801;&#x5F00;&#x542F;&#x7F13;&#x51B2;&#x8BBE;&#x7F6E;</span>
ob_start();
</code></pre>
<h2 id="php&#x5982;&#x4F55;&#x5B9E;&#x73B0;&#x9875;&#x9762;&#x7EAF;&#x9759;&#x6001;&#x5316;">PHP&#x5982;&#x4F55;&#x5B9E;&#x73B0;&#x9875;&#x9762;&#x7EAF;&#x9759;&#x6001;&#x5316;</h2>
<p>&#x57FA;&#x672C;&#x65B9;&#x6CD5;</p>
<ol>
<li>file_put_contents() &#x5C06;&#x4E00;&#x4E2A;&#x5B57;&#x7B26;&#x4E32;&#x5199;&#x5165;&#x6587;&#x4EF6;&#x5185;&#x90E8;</li>
<li>output_buffering &#x4F7F;&#x7528;PHP&#x5185;&#x7F6E;&#x7F13;&#x5B58;&#x673A;&#x5236;&#x5B9E;&#x73B0;&#x9875;&#x9762;&#x9759;&#x6001;&#x5316;</li>
</ol>
<table>
<thead>
<tr>
<th>&#x51FD;&#x6570;</th>
<th>&#x5907;&#x6CE8;</th>
</tr>
</thead>
<tbody>
<tr>
<td>ob_start</td>
<td>&#x6253;&#x5F00;&#x8F93;&#x51FA;&#x63A7;&#x5236;&#x7F13;&#x5B58;</td>
</tr>
<tr>
<td>ob_get_contents</td>
<td>&#x8FD4;&#x56DE;&#x8F93;&#x51FA;&#x7F13;&#x5B58;&#x533A;&#x5185;&#x5BB9;</td>
</tr>
<tr>
<td>ob_clean</td>
<td>&#x6E05;&#x7A7A;&#x8F93;&#x51FA;&#x7F13;&#x51B2;&#x533A;</td>
</tr>
<tr>
<td>ob_get_clean</td>
<td>&#x5F97;&#x5230;&#x5F53;&#x524D;&#x7F13;&#x51B2;&#x533A;&#x5185;&#x5BB9;&#x5E76;&#x5220;&#x9664;&#x5F53;&#x524D;&#x8F93;&#x51FA;&#x7F13;&#x51B2;&#x533A;</td>
</tr>
</tbody>
</table>
<pre><code class="lang-php">file_put_contents(<span class="hljs-string">&apos;index.shtml&apos;</span>, <span class="hljs-string">&apos;test string&apos;</span>);
</code></pre>
<h2 id="php&#x7EAF;&#x9759;&#x6001;&#x5316;&#x6848;&#x4F8B;&#x5B9E;&#x73B0;">PHP&#x7EAF;&#x9759;&#x6001;&#x5316;&#x6848;&#x4F8B;&#x5B9E;&#x73B0;</h2>
<p>&#x5168;&#x90E8;&#x7EAF;&#x9759;&#x6001;&#x5316;&#x6848;&#x4F8B;</p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="./" class="navigation navigation-prev " aria-label="Previous page: 随手笔记">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="../../interview/" class="navigation navigation-next " aria-label="Next page: 面试相关">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"PHP页面静态化","level":"1.3.2.1","depth":3,"next":{"title":"面试相关","level":"1.4","depth":1,"path":"docs/interview/README.md","ref":"docs/interview/README.md","articles":[]},"previous":{"title":"随手笔记","level":"1.3.2","depth":2,"path":"docs/php/随手笔记/README.md","ref":"docs/php/随手笔记/README.md","articles":[{"title":"PHP页面静态化","level":"1.3.2.1","depth":3,"path":"docs/php/随手笔记/PHP页面静态化.md","ref":"docs/php/随手笔记/PHP页面静态化.md","articles":[]}]},"dir":"ltr"},"config":{"plugins":["-sharing","include-codeblock","alerts","sitemap-general","favicon","github","terminal","toggle-chapters"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"github":{"url":"https://gitee.com/tonygeli/"},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sitemap-general":{"prefix":"http://gitbook.zhangjikai.com"},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"favicon":{"shortcut":"./assets/images/favicon.ico","bookmark":"./assets/images/favicon.ico","appleTouch":"./assets/images/wukong.png","appleTouchMore":{"120x120":"./assets/images/wukong.png","180x180":"./assets/images/wukong.png"}},"alerts":{},"include-codeblock":{"check":false,"edit":false,"fixlang":false,"lang":"","template":"ace","theme":"monokai","unindent":true},"terminal":{"copyButtons":true,"fade":false,"style":"flat"},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"toggle-chapters":{}},"theme":"default","author":"laiq","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"language":"zh-hans","gitbook":"*","description":"学习记录与分享"},"file":{"path":"docs/php/随手笔记/PHP页面静态化.md","mtime":"2018-10-30T05:46:41.000Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-11-01T05:28:55.014Z"},"basePath":"../../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../../gitbook/gitbook.js"></script>
    <script src="../../../gitbook/theme.js"></script>
    
        
        <script src="../../../gitbook/gitbook-plugin-alerts/plugin.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-github/plugin.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-terminal/plugin.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-toggle-chapters/toggle.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

